package com.example.utils;

import com.example.pojo.CodeTale;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

@Component
public class CodeUtils {

    private String [] patch = {"00000","0000","000","00","0",""};

    public String sendCode(String tela){
        long hash  = tela.hashCode();
        long ensyc = 20241230;
        long result = hash ^ ensyc;
        long nowTime = System.currentTimeMillis();
        result = result ^ nowTime;
        long code = result % 1000000;
        code = code<0 ? -code : code;
        String codeString = code +"";
        int len = codeString.length();
        return patch[len-1] + codeString;
    }

    @Cacheable(value = "smsCode",key = "#tela")
    public String getCode(String tela){
        return null;
    }
}
